load("//bzl:cpp_library.bzl", "cpp_library")

package(default_visibility = ["//visibility:public"])

cpp_library(
    name = "channel",
    hdrs = [
        "Channel.h",
        "Channel-fwd.h",
    ],
    textual_hdrs = [
        "Channel-inl.h",
    ],
    deps = [
        "//folly:cancellation_token",
        "//folly:synchronized",
        "//folly/coro:coroutine",
        "//folly/experimental/channels/detail:channel_bridge",
    ],
)

cpp_library(
    name = "channel_callback_handle",
    hdrs = [
        "ChannelCallbackHandle.h",
    ],
    deps = [
        "//folly:intrusive_list",
        "//folly:scope_guard",
        "//folly/channels:channel",
    ],
)

cpp_library(
    name = "channel_processor",
    hdrs = [
        "ChannelProcessor.h",
    ],
    textual_hdrs = [
        "ChannelProcessor-inl.h",
    ],
    deps = [
        "//folly:executor",
        "//folly/channels:consume_channel",
        "//folly/channels:merge_channel",
        "//folly/channels:rate_limiter",
        "//folly/channels:transform",
        "//folly/executors:serial_executor",
        "//folly/experimental/channels/detail:intrusive_ptr",
    ],
)

cpp_library(
    name = "consume_channel",
    hdrs = [
        "ConsumeChannel.h",
    ],
    textual_hdrs = [
        "ConsumeChannel-inl.h",
    ],
    deps = [
        "//folly:executor",
        "//folly:format",
        "//folly:intrusive_list",
        "//folly:scope_guard",
        "//folly/channels:channel",
        "//folly/channels:channel_callback_handle",
        "//folly/coro:task",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:utility",
    ],
)

cpp_library(
    name = "fanout_channel",
    hdrs = [
        "FanoutChannel.h",
    ],
    textual_hdrs = [
        "FanoutChannel-inl.h",
    ],
    deps = [
        "//folly/channels:channel",
        "//folly/channels:fanout_sender",
        "//folly/container:f14_hash",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:utility",
    ],
)

cpp_library(
    name = "fanout_sender",
    hdrs = [
        "FanoutSender.h",
    ],
    textual_hdrs = [
        "FanoutSender-inl.h",
    ],
    deps = [
        "//folly/channels:channel",
        "//folly/container:f14_hash",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:pointer_variant",
        "//folly/experimental/channels/detail:utility",
    ],
)

cpp_library(
    name = "merge",
    hdrs = [
        "Merge.h",
    ],
    textual_hdrs = [
        "Merge-inl.h",
    ],
    deps = [
        "//folly/channels:channel",
        "//folly/container:f14_hash",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:utility",
    ],
)

cpp_library(
    name = "merge_channel",
    hdrs = [
        "MergeChannel.h",
    ],
    textual_hdrs = [
        "MergeChannel-inl.h",
    ],
    deps = [
        "//folly/channels:channel",
        "//folly/container:f14_hash",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:utility",
    ],
)

cpp_library(
    name = "multiplex_channel",
    hdrs = [
        "MultiplexChannel.h",
    ],
    textual_hdrs = [
        "MultiplexChannel-inl.h",
    ],
    deps = [
        "//folly/channels:channel",
        "//folly/channels:fanout_sender",
        "//folly/channels:on_closed_exception",
        "//folly/channels:rate_limiter",
        "//folly/container:f14_hash",
        "//folly/coro:future_util",
        "//folly/coro:mutex",
        "//folly/coro:promise",
        "//folly/coro:task",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:multiplexer_traits",
        "//folly/experimental/channels/detail:utility",
        "@range-v3",
    ],
)

cpp_library(
    name = "on_closed_exception",
    hdrs = [
        "OnClosedException.h",
    ],
)

cpp_library(
    name = "producer",
    hdrs = [
        "Producer.h",
    ],
    textual_hdrs = [
        "Producer-inl.h",
    ],
    deps = [
        "//folly:cancellation_token",
        "//folly/channels:channel",
        "//folly/channels:channel_callback_handle",
        "//folly/channels:consume_channel",
        "//folly/coro:task",
        "//folly/executors:sequenced_executor",
        "@fmt",
    ],
)

cpp_library(
    name = "proxy_channel",
    hdrs = [
        "ProxyChannel.h",
    ],
    textual_hdrs = [
        "ProxyChannel-inl.h",
    ],
    deps = [
        "//folly/channels:channel",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:utility",
    ],
)

cpp_library(
    name = "rate_limiter",
    hdrs = [
        "RateLimiter.h",
    ],
    deps = [
        "//folly:function",
        "//folly/executors:sequenced_executor",
    ],
)

cpp_library(
    name = "max_concurrent_rate_limiter",
    srcs = [
        "MaxConcurrentRateLimiter.cpp",
    ],
    hdrs = [
        "MaxConcurrentRateLimiter.h",
    ],
    deps = [
        "//folly:synchronized",
        "//folly/channels:rate_limiter",
        "//folly/concurrency:unbounded_queue",
        "//folly/executors:sequenced_executor",
    ],
)

cpp_library(
    name = "transform",
    hdrs = [
        "Transform.h",
    ],
    textual_hdrs = [
        "Transform-inl.h",
    ],
    deps = [
        "//folly/channels:channel",
        "//folly/channels:on_closed_exception",
        "//folly/channels:rate_limiter",
        "//folly/coro:async_generator",
        "//folly/coro:task",
        "//folly/executors:sequenced_executor",
        "//folly/experimental/channels/detail:utility",
    ],
)
